<template>
  <div class="Mine-box">
    <van-nav-bar title="奇葩朵朵开" />
    <!-- 头像部分 -->
    <div class="Mine-One">
      <!-- 头像左边 -->
      <div class="Mine-left">
        <div class="Mine-left-one">
          <img src="http://81.68.133.139:3000/images/mine/photo.png" alt="" />
        </div>
      </div>
      <!-- 头像右边 -->
      <div class="Mine-right">
        <ul>
          <li v-for="item in list" :key="item">
            <p class="item-num">{{ item.num }}</p>
            <p class="item-sizi">{{ item.sizi }}</p>
          </li>
        </ul>
        <!-- 完善个人信息 -->
        <div class="Mine-personal-information" @click="handleClick">
          <p>完善个人信息</p>
        </div>
      </div>
    </div>
    <!-- 优惠券 -->
    <div class="discount-coupon">
      <ul>
        <li v-for="item in discount" :key="item">
          <img :src="item.img" alt="" />
          <span>{{ item.title }}</span>
        </li>
      </ul>
    </div>
    <!-- 我的宠物 -->
    <div class="my-pet">
      <div>
        <van-nav-bar left-text="我的宠物">
          <template #right
            ><div @click="push">查看所有宠物 <van-icon name="arrow" /></div
          ></template>
        </van-nav-bar>
      </div>
      <!-- 板块一 -->
      <div class="my-petimg" v-if="!list1">
        <img src="http://81.68.133.139:3000/images/mine/cat.png" alt="" />
        <p class="my-petsizi">天呐，居然连只宠物都没有</p>
        <van-button type="primary" to="/addpet" color="orange"
          ><span>添加宠物</span></van-button
        >
      </div>
      <!-- 板块二 -->
      <div class="my-peting2" v-if="list1">
        <ul>
          <li v-for="item in list3" :key="item.petId">
            <div class="peting-one">
              <div class="peting-two">
                <img
                  src="http://81.68.133.139:3000/images/addpet/petheart.png"
                  alt=""
                />
              </div>
              <div class="peting-three">
                <p class="three1">{{ item.petBreed }}</p>
                <p class="three2">{{ item.petName }}</p>
              </div>
            </div>
            <!-- <div class="peting-four"></div> -->
          </li>
          <div class="my-peting3">
            <div class="add" @click="AddPet">
              <van-icon name="add-o" size="60" />
            </div>
            <p class="add-tow">新增宠物</p>
          </div>
        </ul>
      </div>
    </div>
    <!-- 我的订单 -->
    <div class="my-order-box">
      <van-nav-bar left-text="我的订单">
        <template #right
          ><div @click="order">查看全部 <van-icon name="arrow" /></div
        ></template>
      </van-nav-bar>
    </div>
    <!-- 订单图标 -->
    <div class="my-order">
      <ul>
        <li v-for="item in myorder" :key="item">
          <img :src="item.icon" alt="" />
          <p>{{ item.font }}</p>
        </li>
      </ul>
    </div>
    <!-- 我的发布 -->
    <div class="my-release">
      <ul>
        <li v-for="item in release" :key="item">
          <img :src="item.imgs" alt="" />
          <p>{{ item.title }}</p>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { mapActions, mapState } from "vuex";
export default {
  setup() {
    // 头像部分的li
    const list = [
      {
        num: 0,
        sizi: "关注",
      },
      {
        num: 0,
        sizi: "粉丝",
      },
      {
        num: 0,
        sizi: "被赞",
      },
    ];
    // 优惠券
    const discount = [
      {
        img: "http://81.68.133.139:3000/images/mine/discount.png",
        title: "优惠券：10",
      },
      {
        img: "http://81.68.133.139:3000/images/mine/grain.png",
        title: "狗粮：0",
      },
    ];

    //我的订单
    const myorder = [
      {
        icon: "http://81.68.133.139:3000/images/mine/con-1.png",
        font: "待付款",
      },
      {
        icon: "http://81.68.133.139:3000/images/mine/con-2.png",
        font: "待发货",
      },
      {
        icon: "http://81.68.133.139:3000/images/mine/con-3.png",
        font: "待收货",
      },
      {
        icon: "http://81.68.133.139:3000/images/mine/con-4.png",
        font: "待评价",
      },
      {
        icon: "http://81.68.133.139:3000/images/mine/con-5.png",
        font: "退款售后",
      },
    ];
    // 我的发布
    const release = [
      {
        imgs: "http://81.68.133.139:3000/images/mine/issue.png",
        title: "我的发布",
      },
      {
        imgs: "http://81.68.133.139:3000/images/mine/collect.png",
        title: "我的收藏",
      },
      {
        imgs: "http://81.68.133.139:3000/images/mine/try-out.png",
        title: "我的试用",
      },
      {
        imgs: "http://81.68.133.139:3000/images/mine/record.png",
        title: "养护记录",
      },
    ];

    return {
      list,
      discount,
      myorder,
      release,
    };
  },
  data() {
    return {
      list1: "false",
      list2: [],
      list3: [],
    };
  },
  async created() {
    await this.getUserInfo({ uid: localStorage.getItem("userid") });
    //  数据渲染
    await this.getUerMinepets({ uid: localStorage.getItem("userid") });
    this.list2 = this.minepets;
    this.list2.forEach((val) => {
      this.list3.push(val);
    });
    if (this.minepets) {
      this.list1 = true;
    }
  },

  computed: {
    ...mapState("mine", ["userInfo", "minepets"]),
  },
  methods: {
    ...mapActions("mine", ["getUserInfo", "getUerMinepets"]),
    handleClick() {
      this.$router.push("/changeinfo");
    },
    push() {
      this.$router.push("/minepet");
    },
    order() {
      this.$router.push("/order");
    },
    AddPet() {
      this.$router.push("/addpet");
    },
  },
};
</script>

<style lang="less">
.Mine-box {
  .van-nav-bar__title {
    font-size: 20px;
    margin-top: 2px;
    font-weight: 600;
  }
  // 头像部分
  .Mine-One {
    width: 100%;
    height: 130px;
    margin-top: 10px;
    background: white;
    display: flex;
    justify-content: space-around;
    padding-left: 5px;
    .Mine-left {
      width: 35%;
      height: 120px;
      .Mine-left-one {
        width: 100px;
        height: 100px;
        border: 2px #c4c0c0 solid;
        border-radius: 50%;
        margin-top: 20px;
        img {
          width: 65px;
          height: 65px;
          margin-top: 20px;
          margin-left: 15px;
        }
      }
    }
    .Mine-right {
      height: 120px;
      ul {
        display: flex;
        justify-content: space-between;
        margin-top: 10px;
        li {
          width: 50px;
          height: 60px;
          .item-num {
            font-size: 25px;
            text-align: center;
            margin-top: 10px;
            height: 10px;
            font-weight: 700;
          }
          .item-sizi {
            font-size: 15px;
            text-align: center;
            font-weight: 600;
            color: #a5a5a5;
            margin-top: 30px;
          }
        }
      }
      .Mine-personal-information {
        width: 210px;
        height: 40px;
        background: rgb(241, 239, 239);
        font-size: 20px;
        margin-top: 15px;
        p {
          margin-left: 40px;
          font-weight: 600;
          line-height: 40px;
          margin-top: 10px;
        }
      }
    }
  }
  // 优惠劵
  .discount-coupon {
    width: 100%;
    height: 60px;
    background: white;
    box-sizing: border-box;
    border: 1px solid #e6e0e0;
    ul {
      display: flex;
      justify-content: space-around;
      align-items: center;
      margin-top: 10px;
      li {
        height: 60px;
        display: flex;
        justify-content: space-around;
        img {
          width: 25px;
          height: 25px;
          margin-top: 10px;
        }
        span {
          display: block;
          flex: 1;
          font-size: 18px;
          margin-top: 10px;
          margin-left: 10px;
        }
      }
    }
  }
  // 我的宠物
  .my-pet {
    width: 100%;
    height: 300px;
    margin-top: 7px;
    .van-nav-bar__text {
      font-size: 17px;
      font-weight: 600;
      color: black;
    }
    .van-nav-bar__right {
      font-size: 15px;
      color: #c2c2c2;
    }
    .van-badge__wrapper {
      color: #c2c2c2;
    }
    .my-petimg {
      width: 100%;
      height: 150px;
      padding-top: 10px;
      img {
        width: 140px;
        height: 140px;
        margin-left: 130px;
      }
      .my-petsizi {
        width: 100%;
        margin-top: 10px;
        text-align: center;
        color: #aaaaaa;
        font-size: 20px;
      }
      .van-button {
        width: 200px;
        font-size: 20px;
        font-weight: 600;
        margin-left: 100px;
        span {
          color: black;
        }
      }
    }
    .my-peting2 {
      display: flex;
      justify-content: space-around;
      align-items: center;
      width: 100%;
      height: 255px;
      background: white;

      ul {
        display: flex;
        width: 100%;
        overflow: auto;
        &::-webkit-scrollbar {
          width: 0px;
          display: none;
        }
        li {
          width: 200px !important;
          height: 200px;
          margin-left: 5px;
          border: 2px #d6d5d5 solid;
          box-shadow: 0px 0px 2px 0px #ababab;
          flex-shrink: 0;
          .peting-one {
            width: 100%;
            height: 100px;
            margin-top: -3px;
            display: flex;
            justify-content: space-around;
            align-items: center;
            flex: 1;
            .peting-two {
              img {
                width: 70px;
                height: 70px;
                border-radius: 50%;
              }
            }
            .peting-three {
              width: 100%;
              height: 80px;

              .three1 {
                width: 100%;
                height: 40px;
                font-size: 20px;
                line-height: 40px;
                font-weight: 600;
                margin-top: -2px;
              }
              .three2 {
                width: 100%;
                height: 40px;
                font-size: 19px;
                font-weight: 600;
                line-height: 40px;
                margin-top: -8px;
              }
            }
          }
          .peting-four {
            width: 80px;
            height: 80px;
          }
        }
      }
      .my-peting3 {
        border: 1px #ababab solid;

        .add {
          width: 70px;
          height: 70px;
          margin: 0 auto;
          background: white;
          .van-badge__wrapper {
            // margin-left: -14px;
            margin-top: 15px;
            color: black !important;
          }
        }
        .add-tow {
          text-align: center;
          width: 100%;
          height: 40px;
          font-size: 20px;
        }
      }
    }
    .my-peting3 {
      width: 150px;
      height: 200px;
      margin-left: 10px;
    }
  }
  // 我的订单

  .my-order-box {
    .van-nav-bar__text {
      font-size: 17px;
      font-weight: 600;
      color: black;
    }
    .van-badge__wrapper {
      font-size: 15px;
      color: #c2c2c2;
    }
    .van-nav-bar__right {
      font-size: 15px;
      color: #c2c2c2;
    }
  }
  //订单图标
  .my-order {
    width: 100%;
    height: 70px;
    margin-top: 7px;
    background: white;
    ul {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-top: 10px;
      li {
        width: 100%;
        img {
          width: 30px;
          height: 30px;
          margin-left: 20px;
        }
        p {
          font-size: 14px;
          text-align: center;
          font-weight: 600;
        }
      }
    }
  }
  //我的发布
  .my-release {
    width: 100%;
    height: 70px;
    background: white;
    margin-top: 7px;
    margin-bottom: 50px;
    ul {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-top: 7px;
      li {
        width: 100%;
        img {
          width: 35px;
          height: 35px;
          margin-left: 27px;
        }
        p {
          font-size: 14px;
          text-align: center;
          font-weight: 600;
        }
      }
    }
  }
}
</style>
